NOTE: Not every geographical location works well with pandas datareader, your firewall may also block it!
Functions from pandas_datareader.data and pandas_datareader.wb extract data from various Internet sources into a pandas DataFrame. Currently the following sources are supported:
It should be noted, that various sources support different kinds of data, so not all sources implement the same methods and the data elements returned might also differ.
In [1]:
import pandas_datareader.data as web
import datetime
start = datetime.datetime(2015, 1, 1)
end = datetime.datetime(2017, 1, 1)
facebook = web.DataReader("FB", 'google', start, end)
In [2]:
facebook.head()
Out[2]:
The Options class allows the download of options data from Google Finance.
The get_options_data method downloads options data for specified expiry date and provides a formatted DataFrame with a hierarchical index, so its easy to get to the specific option you want.
Available expiry dates can be accessed from the expiry_dates property.
In [3]:
from pandas_datareader.data import Options
fb_options = Options('FB', 'google')
In [4]:
data = fb_options.get_options_data(expiry = fb_options.expiry_dates[0])
In [5]:
data.head()
Out[5]:
In [6]:
import pandas_datareader.data as web
import datetime
start = datetime.datetime(2010, 1, 1)
end = datetime.datetime(2017, 1, 1)
gdp = web.DataReader("GDP", "fred", start, end)
In [7]:
gdp.head()
Out[7]: